*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Pager 2006 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/pager112.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "Pager_Final.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab race1
tab race1, nol
gen whiteR = race1
recode whiteR (2=0)
tab whiteR
replace whiteR = 0 if latino != 2
tab whiteR race1
tab whiteR latino

tab race2
tab race2, nol
gen blackR = race2
recode blackR (2=0)
tab blackR
replace blackR = 0 if latino != 2
tab blackR race2
tab blackR latino

tab latino
tab latino, nol
gen hispnR = latino
recode hispnR (2 8 9=0)
tab latino hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab PAG1CON1
tab PAG1CON1, nol
gen Rblack = PAG1CON1
recode Rblack (2/3=0) (1=1)
gen Rwhite = PAG1CON1
recode Rwhite (1 3=0) (2=1)
gen Rnorace = PAG1CON1
recode Rnorace (1 2=0) (3=1)
tab PAG1CON1 Rblack  // black Michael
tab PAG1CON1 Rwhite  // white Michael
tab PAG1CON1 Rnorace // nonracial Michael

tab PAG1CON2
tab PAG1CON2, nol
gen Ulaid = PAG1CON2
recode Ulaid (2/3=0) (1=1)
gen Ufired = PAG1CON2
recode Ufired (1 3=0) (2=1)
gen Uprison = PAG1CON2
recode Uprison (1 2=0) (3=1)
tab PAG1CON2 Ulaid   // laid off Michael
tab PAG1CON2 Ufired  // fired Michael
tab PAG1CON2 Uprison // imprisoned Michael

tab PAG1CON3
tab PAG1CON3, nol
gen Ddepend = PAG1CON3
recode Ddepend (2=0) (1=1)
gen Dundepend = PAG1CON3
recode Dundepend (1=0) (2=1)
tab PAG1CON3 Ddepend   // dependable Michael
tab PAG1CON3 Dundepend // undependable Michael

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab train1
tab train1, nol
gen GHtrain3 = train1
recode GHtrain3 (8 9=.) (3=-1) (2=0) (1=1)
tab train1 GHtrain3 // training variable with three levels

tab cash1
tab cash1, nol
gen GHcash3 = cash1
recode GHcash3 (8 9=.) (3=-1) (2=0) (1=1)
tab cash1 GHcash3   // cash variable with three levels

tab train1
tab train1, nol
tab train2
tab train2, nol
tab train2 train1, mi
gen GHtrain11 = train2
recode GHtrain11 (98 99=.)
sum GHtrain11
replace GHtrain11 = 0 if train1==3  // none at all training (from train1)
replace GHtrain11 = 11 if train1==1 // a lot of training (from train1)
replace GHtrain11 = 5 if train1==2 & (train2==98 | train2==99)
sum GHtrain11
tab GHtrain11 train1, mi
tab GHtrain11 train2, mi
egen GHtrain11_std = std(GHtrain11)
sum GHtrain11_std

tab cash1
tab cash1, nol
tab cash2
tab cash2, nol
gen GHcash11 = cash2
sum GHcash11
recode GHcash11 (98 99=.)
sum GHcash11
replace GHcash11 = 0 if cash1==3
replace GHcash11 = 11 if cash1==1
replace GHcash11 = 5 if cash1==2 & (cash2==98 | cash2==99)
tab GHcash11 cash1, mi
tab GHcash11 cash2, mi
egen GHcash11_std = std(GHcash11)
sum GHcash11_std

alpha GHtrain11_std GHcash11_std, item std min(1) gen(ALPHA)
pwcorr ALPHA GHtrain11_std GHcash11_std

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

sum ALPHA if hispnR==1
di r(sd)
gen ov_hispn_std = ALPHA/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

tab mikerace
tab mikerace, nol
gen recallrace = 0
replace recallrace = 1 if Rblack == 1 & mikerace == 2
replace recallrace = 1 if Rwhite == 1 & mikerace == 1
replace recallrace = . if Rnorace == 1
tab recallrace if white==1
tab white if Rnorace!=1

tab recallrace
tab recallrace if Rnorace==0
tab recallrace if white==1
tab recallrace if black==1

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std Rblack Rnorace Ulaid Ufired Ddepend PAG1RAN if whiteR==1 & Rnorace==0
reg ov_black_std Rblack Rnorace Ulaid Ufired Ddepend PAG1RAN if blackR==1 & Rnorace==0
reg ov_hispn_std Rblack Rnorace Ulaid Ufired Ddepend PAG1RAN if hispnR==1 & Rnorace==0
